from erpnext.accounts.doctype.payment_entry.payment_entry import PaymentEntry

class CustomPaymentEntry(PaymentEntry):
    def validate_payment_against_orders(self):
        # 复制并修改原方法逻辑
        for d in self.get("references"):
            if d.reference_doctype in ["Sales Order", "Purchase Order"] and flt(d.allocated_amount) == 0:
                # 跳过0金额验证 :cite[1]
                continue
            # 保留原始验证逻辑
            super().validate_payment_against_orders()